{{define "setting/index.html"}}
<!DOCTYPE html>
<html lang="en">
{{template "common/header.html" .}}

<body>
    <div id="wrapper">
        {{template "common/navbar.html" .}}
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-8">
                    <h1 class="page-header">配置管理</h1>
                </div>
                <!-- /.col-lg-12 -->
                <div class="col-lg-4">
                    <div>
                        <div id="alert-success" class="alert alert-success fade in hidden">
                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                            <strong class="title">Success!</strong>
                            <span class="message">Your message has been sent successfully.</span>
                        </div>
                    </div>
                    <div>
                        <div id="alert-error" class="alert alert-danger fade in hidden">
                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                            <strong class="title">Error!</strong>
                            <span class="message">Your message has been sent Error.</span>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Data Configs <a href="/admin/setting/new"><i class="fa fa-plus-circle"></i> Add New</a>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-config">
                                    <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>Group</th>
                                            <th>Key</th>
                                            <th>Value</th>
                                            <th>Comment</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {{range $k, $v := .data}}
                                        <tr>
                                            <td>{{.ID}}</td>
                                            <td>{{.Group}}</td>
                                            <td>{{.Key}}</td>
                                            <td style="max-width:100px;height:auto;">{{.Value}}</td>
                                            <td style="max-width:100px;height:auto;">{{.Comment}}</td>
                                            <td class="center">
                                                <span><a href="/admin/setting/edit/{{.Key}}"><i class="fa fa-2x fa-pencil-square"></i></a></span>
                                                <span><a  class="config-delete" href="javascript:void();" data-href="/admin/setting/delete/{{.Key}}"><i class="fa fa-2x  fa-minus-square"></i></a></span>
                                            </td>
                                        </tr>
                                        {{end}}
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
    {{template "common/footer.html" .}}

    <script>
        $(document).ready(function() {
            $(".config-delete").bind("click",function(){
                if (window.confirm("Are you sure you want to delete this config?")) {
                    $.post($(this).attr("data-href"), null, function(data, status){
                        if (data && data['error']){
                            $("#alert-error .message").text(data['error']);
                            $("#alert-error").removeClass("hidden").addClass("show");
                        } else if (data && data['message']) {
                            $("#alert-success .message").text(data['message']);
                            $("#alert-success").removeClass("hidden").addClass("show");
                        }
                        window.location.reload();
                    });
                }
            });
        });
    </script>
    <script>
    $(document).ready(function() {
        $('#dataTables-config').DataTable({
            responsive: true,
        });
    });
    </script>
</body>

</html>
{{end}}